""" Make the mechanical risk index

"""

import pandas as pd
import utils

#%% SETUP CONFIGURATION -----------------------------------------------------------------
data_folder = 'data_py'
mri_columns = [
    'total_depth',
    'vertical_depth',
    'water_depth',
    'n_strings',
    'max_mud_weight',
    'botm_longitude',
    'botm_latitude',
    'surf_longitude',
    'surf_latitude'
]

#%% GET DATA ----------------------------------------------------------------------------
df = pd.read_csv('./data_py/temp/02_combine_wells/permits_clean.csv')
for i in mri_columns:
    df[i] = pd.to_numeric(df[i], errors='coerce')

#%% BUILD THE MECHANICAL RISK INDEX -----------------------------------------------------
df = (
    df
    .assign(
        horizontal_displacement=lambda x: x.apply(utils.geodesic_by_row, axis=1),
        phi_1=lambda x: utils.phi_1(x),
        phi_2=lambda x: utils.phi_2(x),
        phi_3=lambda x: utils.phi_3(x),
        phi_4=lambda x: utils.phi_4(x),
        mri=lambda x: utils.mri(x)
    )
    .pipe(
        utils.to_csv_return,
        path=f"./{data_folder}/temp/03_make_mri/wells_with_mri.csv"
    )
)


